package com.corn.servlet;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.Enumeration;


public class HelloServlet implements Servlet {

    private String username;

    public HelloServlet(){
        System.out.println("创建了Servlet对象");
    }

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        System.out.println(servletConfig.getServletName());
        this.username = servletConfig.getInitParameter("username");
        Enumeration<String> enumeration = servletConfig.getInitParameterNames();
        while (enumeration.hasMoreElements()) {
            String element = enumeration.nextElement();
            System.out.println(servletConfig.getInitParameter(element));
        }


        System.out.println("对Servlet完成初始化操作>>>");
    }
    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("执行了Servlet业务方法>>>");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("释放了Servlet对象>>>");
    }
}
